/*
* @Author: Administrator
* @Date:   2017-01-16 17:00:40
* @Last Modified by:   Administrator
* @Last Modified time: 2017-01-18 11:17:36
*/

'use strict';

// 点击checKbox 选中
var checkBox =document.querySelectorAll('input[type="checkbox"]');
var itemCheck=document.querySelectorAll('.item-check');
var checkAll=document.querySelector('#checkAll');

for (var i = 0; i<itemCheck.length;i++){
	itemCheck[i].addEventListener('click',function(){
		this.classList.toggle('checked');
	})
}

checkAll.addEventListener('click',function(){
		this.classList.toggle('checked');
	if(checkAll.classList.contains('checked')){
		for(var i=0;i<itemCheck.length;i++){
			itemCheck[i].classList.add('checked');
			checkBox[i+1].checked=true;
		}
	}else{
		for(var i=0;i<itemCheck.length;i++){
			itemCheck[i].classList.remove('checked');
			checkBox[i+1].checked=false;
		}
	}
})

var del=document.querySelectorAll('.txt-b-r');
// var delT=document.querySelectorAll('.del-t');
var delT=null;
var overpop=document.querySelector('.overpop');
for(var i=0;i<del.length;i++){
	del[i].addEventListener('click',function(){
		delT=this.children[0]
		delT.style.transform="rotate(-20deg) translate(-2px,-2px)"
		overpop.style.display="block";
	})
}
     

var cancel=document.querySelector('.cancel');
cancel.addEventListener('click',function(){
	overpop.style.display="none";
	delT.style.transform="none";
})                                


var jia=document.querySelectorAll('.jian');
var jian=document.querySelectorAll('.jia');
var num=document.querySelectorAll('.num');

for (var i=0;i<jia.length;i++){
	jia[i].addEventListener('touchstart',function(){
		var val=this.parentNode.children[1].children[0].value;
		val++;
		this.parentNode.children[1].children[0].value=val;
		this.classList.add('delc');
	})
	jia[i].addEventListener('touchend',function(){
		this.classList.remove('delc');
	})
	
	jian[i].addEventListener('touchstart',function(){
		var val=this.parentNode.children[1].children[0].value;
		val--;
		if(val<=0){
			val=0;
			return false;
		}
		this.parentNode.children[1].children[0].value=val;
		this.classList.add('delc');
	})
	jian[i].addEventListener('touchend',function(){
		this.classList.remove('delc');
	})
}